﻿package mortal.game.view.ranking.view
{
    import com.gengine.core.frame.*;
    import com.gengine.global.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import flash.events.*;
    import frEngine.primitives.object2d.*;
    import mortal.component.rotate3dModelSprite.*;
    import mortal.component.window.*;
    import mortal.game.resource.*;
    import mortal.game.scene3D.player.entity.*;
    import mortal.game.view.common.*;

    public class RoleEquipDisplayPanelBase extends Model3DdisplayPanelBase
    {
        protected var _window:Window;
        protected var _roleModelBg:GImageBitmap;
        protected var _equipPanel:RankLookPlayerEquipPark;
        protected var _leftBtn:GLoadedButton;
        protected var _rightBtn:GLoadedButton;
        protected var _img2d:Img2D;
        protected var _roleModelPlayer:UserModelPlayer;
        protected var _rotate3d:Rotate3dModelSprite;
        protected var _scale9gridImg2d:Scale9GridImg2DEx;
        private var turnValue:int;
        private var _frameTimer:FrameTimer;

        public function RoleEquipDisplayPanelBase(param1:Window)
        {
            this._window = param1;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._rotate3d = UIFactory.getUICompoment(Rotate3dModelSprite, 42, 120, this);
            this._rotate3d.setSize(165, 273);
            this._roleModelBg = UIFactory.gImageBitmap("", 0, 0, null, this.onBgLoadCompl);
            this._leftBtn = UIFactory.gLoadedButton(ImagesConst.TurnLeft2_upSkin, 166, 356, 40, 36, this);
            this._leftBtn.configEventListener(MouseEvent.MOUSE_DOWN, this.onClickTurnBtn);
            this._rightBtn = UIFactory.gLoadedButton(ImagesConst.TurnRight2_upSkin, 47, 356, 40, 36, this);
            this._rightBtn.configEventListener(MouseEvent.MOUSE_DOWN, this.onClickTurnBtn);
            Global.stage.addEventListener(MouseEvent.MOUSE_UP, this.stopTurning);
            this._equipPanel = UICompomentPool.getUICompoment(RankLookPlayerEquipPark);
            this._equipPanel.createDisposedChildren();
            this._equipPanel.x = 0;
            this._equipPanel.y = 0;
            this.addChild(this._equipPanel);
            this.init3DRect();
            return;
        }// end function

        protected function onBgLoadCompl() : void
        {
            return;
        }// end function

        protected function init3DRect() : void
        {
            return;
        }// end function

        protected function updateRoleModel() : void
        {
            return;
        }// end function

        protected function remove3d() : void
        {
            return;
        }// end function

        public function set data(param1:Object) : void
        {
            return;
        }// end function

        protected function onClickTurnBtn(event:MouseEvent) : void
        {
            if (this._roleModelPlayer)
            {
                if (event.currentTarget == this._leftBtn)
                {
                    this.turnValue = 2;
                }
                if (event.currentTarget == this._rightBtn)
                {
                    this.turnValue = -2;
                }
                this.start();
            }
            return;
        }// end function

        protected function stopTurning(event:MouseEvent = null) : void
        {
            if (this._frameTimer)
            {
                this._frameTimer.stop();
            }
            return;
        }// end function

        protected function onTurning(param1:FrameTimer) : void
        {
            if (this._roleModelPlayer)
            {
                this._roleModelPlayer.rotationY = this._roleModelPlayer.rotationY + this.turnValue;
            }
            return;
        }// end function

        private function start() : void
        {
            if (!this._frameTimer)
            {
                this._frameTimer = new FrameTimer(1, int.MAX_VALUE, true);
                this._frameTimer.addListener(TimerType.ENTERFRAME, this.onTurning);
            }
            this._frameTimer.start();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._roleModelBg.dispose();
            this._equipPanel.dispose(param1);
            this._leftBtn.dispose(param1);
            this._rightBtn.dispose(param1);
            this._rotate3d.dispose(param1);
            this._roleModelBg = null;
            this._equipPanel = null;
            this._leftBtn = null;
            this._rightBtn = null;
            this._rotate3d = null;
            this.remove3d();
            return;
        }// end function

    }
}
